package ModelLayer;
import java.util.ArrayList;
/**
 * This class will store the informations about a partikular dvd.
 * 
 * @author (Christian John Schmidt) 
 * @1.0.0 (05.11.2013)
 */
public class Dvd{
    // instance variables - replace the example below with your own
    private String genre;
    private String title;
    private String description;
    private String id;
    private ArrayList<DvdCopy> copies;

    /**
     * Constructor for objects of class Dvd
     */
    public Dvd(String genre, String title, String description, String id)
    {
        this.genre = genre;
        this.title = title;
        this.description = description;
        this.id = id;
        copies = new ArrayList<DvdCopy>();
    }
    
    public void createCopy(String copyNr, String year, double price)
    {
        DvdCopy c = new DvdCopy(copyNr, year, price);
        copies.add(c);
    }
    
    /**
     * This method takes a string input and alters the instance variable.
     */
    public void setGenre(String genre)
    
    {
       this.genre = genre;
    }
    
     /**
     * This method takes a string input and alters the instance variable.
     */
    public void setTitle(String title)
    {
       this.title = title;
    }
    
     /**
     * This method takes a string input and alters the instance variable.
     */
    public void setDescription(String description)
    {
       this.description = description;
    }
    
    public void setId(String id)
    {
        this.id = id;
    }
    
    /**
     * This method will return a String with the information that the instance variable holds
     */
    public String getGenre()
    {
        return genre;
    }
    
    /**
     * This method will return a String with the information that the instance variable holds
     */
    public String getTitle()
    {
        return title;
    }
    
    /**
     * This method will return a String with the information that the instance variable holds
     */
    public String getDescription()
    {
        return description;
    }
    
    /**
     * This method will return a double with the information that the instance variable holds
     */
    public String getId()
    {
        return id;
    }
    
    public void printInformation()
    {
        System.out.println("");
        System.out.println("Title: "+ title);
        System.out.println("Genre: "+ genre);
        System.out.println("Description: "+ description);
        System.out.println("Id: "+ id);
        System.out.println("Number of copies: "+ copies.size());
    }
    
    public DvdCopy findCopy(String copyNr)
    {
        boolean found = false;
        int index = 0;
        int theIndex = 0;
        DvdCopy foundCopy = null;
        while(index < copies.size() && !found)
        {
            if(copies.get(index).getCopyNr().equals(copyNr))
            {
                foundCopy = copies.get(index);
                found = true;
            }
            else
            {
                index++;
            }
        }
        return foundCopy;  
    }
}











